
<template>
  <div class="container">
    <dippingContent
      :operaList="operaList"
      :tableList="tableList"
      :tableData="tableData"
      :res="res"
      :kind="kind"
      :total_count="total_count"
      @getData="getData"
      @deleteData="deleteData"
      @addData="addData"
      @editData="editData"
    >
    </dippingContent>
  </div>
</template>

<script>
import {GetSys} from '@/api/dipping.js'
import { Delete } from '@/api/reusable.js'
import '@/mock/default.js'
import { tableMix } from '@/mixin/tableMix.js'
import { frame2OperaList as operaList } from '@/assets/staticData/operaList/dipping.js'
import { frame2TableList as tableList } from '@/assets/staticData/tableList/dipping.js'
export default {
  name: '',
  components: {},
  props: {},
  mixins: [tableMix], // 一些公用的属性方法可以放在mixin里面,各个组件互不影响
  data () {
    return {}
  },
  computed: {},
  watch: {},
  beforeCreate () {
    // sessionStorage.setItem('activeName', 'qualityRequire')
  },
  created () {
    this.kind = 'frame2'
    // if (sessionStorage.getItem('activeName') === 'qualityRequire') {
    this.getData(
      {
        page: 1, // 因为是在传递时的parmas中 将currentpage传给了page 这个要传page必须和后端字段一致(也就是page 后端写的也是)
        per_page: 10
      }
    )
    // }
  },
  mounted () {
    // this.getData()
  },
  methods: {
    addData (data) {
      this.$axios.get('http://127.0.0.1:7002/addRes')
        .then(res => {
          this.res = res.data
        })
    },
    editData (_id, data) {
      this.$axios.get('http://127.0.0.1:7002/editRes')
        .then(res => {
          // console.log(res)
          this.res = res.data
        })
    },
    getData (data) { // data是当前页和 每页显示多少条
      console.log(data)
      this.operaList = operaList
      this.tableList = tableList
      // this.$axios.get('http://82.156.109.119:7001/v2/GetQuality?collection=qualityrequired')
      // this.$axios.get('http://127.0.0.1:7002/hotOiloneData')
      GetSys(data)
        .then(res => {
          console.log('frame2', res)
          if (res.data.data.results === null) {
            this.tableData = []
          } else {
            this.tableData = res.data.data.results.reverse()
            this.total_count = res.data.data.total_count // 从后端获取全部数据的条目数 无论是搜索过后的还是全部数据
          // console.log(this.count)  12
          }
        })
    },
    deleteData (data) {
      Delete({
        _id: data._id,
        collection: 'dippingsystemnote'
      })
        .then(res => {
          // console.log(res)
          this.res = res
          this.getData({
            page: 1,
            per_page: 10
          })
        })
    }
  }
}
</script>

<style scoped lang="">
</style>
